class Solution
{
public:
    string longestCommonPrefix(vector<string> &strs)
    {
        int pos = 0;
        while (1)
        {
            char tmp = strs[0][pos];
            for (const auto &e : strs)
            {
                if (pos == e.size())
                    return e;
                if (e[pos] != tmp)
                    return e.substr(0, pos);
            }
            ++pos;
        }
        return {};
    }
};